import React,{useEffect} from 'react'
import { ResultPage,Button } from 'antd-mobile'
import { store } from '../../store'
import { NavLink,useLocation ,useNavigate} from 'react-router-dom'
import { useDispatch, useSelector } from "react-redux";
import './payDone.scss'
import API from "../api/order";


export default function PayDone() {
    const user = store.getState().userReducer.user
    const location = useLocation()
    const navigate = useNavigate()
    const { orderReducer } = useSelector((state: any) => state)
    const { _id, token } = store.getState().userReducer.user

    const getOrder = async () => {
      let res = await API['getOrder']({ token })
      console.log(res, '订单列表')
  }

  useEffect(() => {
      getOrder()
  }, [])
    const details = [
        {
          label: '收款方',
          value: user.username,
          bold: true,
        },
        {
          label: '付款方式',
          value: '50000.00',
        },
        {
          label: '转账金额',
          value: orderReducer.order.total+'',
        },
      ]
    return (
        <div>
            <ResultPage
                status='success'
                title='支付成功'
                // description='内容详情可折行，建议不超过两行建议不超过两行建议不超过两行'
                details={details}
            ><Button onClick={()=>navigate('/order')} color='primary' className='pay_btn1'>查看订单</Button>
            <Button onClick={()=>navigate('/')} color='primary' className='pay_btn2'>返回首页</Button></ResultPage>
        
        </div>
    )
}
